package com.benyq.networkprogramme

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.view.MenuItem
import com.benyq.networkprogramme.email.SendMailUtil
import kotlinx.android.synthetic.main.activity_email.*

class EmailActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_email)
        initView()
    }

    private fun initView(){
        mainToolbar.title = "发送邮件"
        setSupportActionBar(mainToolbar)
        mainToolbar.navigationIcon = ContextCompat.getDrawable(this, R.drawable.ic_action_back)

        btnSend.setOnClickListener {
            SendMailUtil.send(etTo.text.toString(), etSubject.text.toString(), etContent.text.toString())
        }
    }

    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        if (item?.itemId == android.R.id.home) {
            finish()
            return true
        }
        return super.onOptionsItemSelected(item)
    }

}
